package com.ld.control.business.process.controller;


import com.ld.control.business.process.service.ProcessNodeExampleService;
import com.ld.control.business.process.vo.resp.NodeExampleStatusResp;
import com.ld.control.business.process.vo.resp.ProcessForNodeRespVo;
import com.ld.control.business.process.vo.resp.ProcessNodeExampleDetailsResp;
import com.ld.control.common.ResultResponse;
import com.ld.control.common.vo.GenerateListVo;
import com.ld.control.sysenum.ResultResponseEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 任务流程节点实例表 前端控制器
 * </p>
 *
 * @author wangfeng
 * @since 2024-05-21
 */
@Slf4j
@Tag(name = "流程节点实例相关接口")
@RestController
public class ProcessNodeExampleController {

    @Autowired
    private ProcessNodeExampleService processNodeExampleService;

    @GetMapping("/api/centralControl/processNodeExample/getDetails")
    @Operation(summary = "获取一个节点实例的详情")
    public ResultResponse<ProcessNodeExampleDetailsResp> getProcessNodeExampleDetails(
            @RequestParam Long processNodeExampleId
    ) {
        ProcessNodeExampleDetailsResp processNodeExampleDetails = processNodeExampleService.getProcessNodeExampleDetails(processNodeExampleId);
        return ResultResponse.success(processNodeExampleDetails);
    }

    @GetMapping("/api/centralControl/processNodeExample/getAllNodeExampleStatus")
    @Operation(summary = "获取某个流程下是所有节点状态")
    public ResultResponse<GenerateListVo<NodeExampleStatusResp>> getAllNodeExampleStatus(
            @RequestParam Long processExampleId
    ) {
        List<NodeExampleStatusResp> processNodeExampleDetails = processNodeExampleService.getAllNodeExampleStatus(processExampleId);
        return ResultResponse.success(new GenerateListVo<>(processNodeExampleDetails));

    }

    @GetMapping("/api/centralControl/processNodeExample/getProcessForNodeInfo")
    @Operation(summary = "获取ProcessFor信息")
    public ResultResponse<GenerateListVo<ProcessForNodeRespVo>> getProcessForNodeInfo(
            @RequestParam Long id
    ) {
        List<ProcessForNodeRespVo> processForNodeInfoList = processNodeExampleService.getProcessForNodeInfo(id);
        return ResultResponse.success(new GenerateListVo<>(processForNodeInfoList));
    }

    @GetMapping("/api/centralControl/processNodeExample/updateConfirmNodeFlag")
    @Operation(summary = "confirm节点确认继续运行")
    public ResultResponse<ResultResponseEnum> updateConfirmNodeFlag(
            @RequestParam Long id
    ) {
        processNodeExampleService.updateConfirmNodeFlag(id);
        return ResultResponse.success();
    }

}
